package linuxbox.bookmark.servlet;

import javax.servlet.http.*;
import org.apache.log4j.Logger;

import linuxbox.common.*;
import linuxbox.bookmark.logic.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

public class BookmarkSettingsAction extends Action
{
  protected static Logger logger = Logger.getLogger(BookmarkSettingsAction.class.getName());

  protected static String listJSP = null;
  protected static String editJSP = null;

  static BookmarkHome home = BookmarkHome.getInstance();

  public void doAction(HttpSession aSession, BoxSession aBoxSession,
                       HttpServletRequest req, HttpServletResponse resp) throws Exception
  {
    String str = req.getParameter("SubmitCancel");
    if ( str != null )
    {
      sendFile(listJSP,req,resp);
      return;
    }

    str = (String) req.getParameter("SubmitSave");
    if ( str != null )
    {
      str = req.getParameter("ENTRIES_IN_HOMEPAGE");
      aBoxSession.setConfigInt("bookmark", "HomePage", "Entries in Homepage", Integer.parseInt(str));

      str = req.getParameter("ENTRIES_PER_PAGE");
      aBoxSession.setConfigInt("bookmark", "General", "Entries Per Page", Integer.parseInt(str));

      aBoxSession.setConfigStrings("bookmark", "HomePage", "Entries", req.getParameterValues("HOMEPAGE_ENTRIES"));
      sendFile(listJSP,req,resp);
      return;
    }

    str = (String) req.getParameter("SubmitEdit");
    if ( str != null )
    {
      sendFile(editJSP,req,resp);
      return;
    }
    sendFile(listJSP, req, resp);
  }

  public void setListJSP(String str)
  {
    listJSP = str;
  }
  public void setEditJSP(String str)
  {
    editJSP = str;
  }
}